#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../include/FileParser.h"


int main(int argc, char** argv) {
    char* files[] =
    {        
        "C:\\Users\\nlucero\\CodeBlocks projects\\Orga6620_TP0_FileParser\\files\\alice.txt",
        "C:\\Users\\nlucero\\CodeBlocks projects\\Orga6620_TP0_FileParser\\files\\beowulf.txt",
        "C:\\Users\\nlucero\\CodeBlocks projects\\Orga6620_TP0_FileParser\\files\\cyclopedia.txt",
        "C:\\Users\\nlucero\\CodeBlocks projects\\Orga6620_TP0_FileParser\\files\\elquijote.txt"
    };

    const unsigned int numFiles = 4;

    FILE* salida = fopen("C:\\Users\\nlucero\\Desktop\\parseo.txt", "w");

    for(int i = 0; i < numFiles; i++) {
        printf("\nParsing: %s\n", files[i]);

        unsigned int wordsCount;
        char** words = FileParser(files[i], &wordsCount);

        for(int j = 0; j < wordsCount; j++) {
            fwrite(words[j], sizeof(char), strlen(words[j]), salida);
            fputs("\n", salida);

            free(words[j]);
        }

        if (words) free(words);
    }
}
